import { ObjCreate } from "../common/ObjCreate";
import { TitleItem } from "../common/item/TitleItem";
import { Language } from "../../../../extend/language/Language";
import { ObjTeamCreate } from "../common/ObjTeamCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { TilePanel } from "../equipment/TilePanel";
import { WrestleViedoCellRenderer } from "./cellRendener/WrestleViedoCellRenderer";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { PageData } from "../arena/ArenaData/PageData";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SWrestleFightRecordInfos } from "../../../../Message/Public/SWrestleFightRecordInfos";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class WrestleVideoPanel
    
    export  class WrestleVideoPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createSpBannerAndBg(0, 0, 802, 450, "", this);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(42347), 215));
            loc1.push(new TitleItem(Language.getString(42348), 60));
            loc1.push(new TitleItem(Language.getString(42349), 65));
            loc1.push(new TitleItem("", 60));
            loc1.push(new TitleItem(Language.getString(42347), 215));
            loc1.push(new TitleItem(Language.getString(42348), 60));
            loc1.push(new TitleItem(Language.getString(42349), 65));
            loc1.push(new TitleItem(Language.getString(42350), 60));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 2, 8, -1, -1, this);
            this._tfNoResult = ObjCreate.createTextField(Language.getString(44251), 390, 210, 200, 20, this, GlobalStyle.textFormat6);
            this._tfNoResult.visible = false;
            this._viedoListPanel = new TilePanel();
            this._viedoListPanel.setSize(802, 420);
            this._viedoListPanel.rowHeight = 42;
            this._viedoListPanel.columnWidth = 802;
            this._viedoListPanel.setStyle("cellRenderer", WrestleViedoCellRenderer);
            this._viedoListPanel.x = 5;
            this._viedoListPanel.y = 30;
            this.addChild(this._viedoListPanel);
            this._pageSelecter = new PageSelecter();
            this._pageSelecter.mode = PageSelecter.InputMode;
            this._pageSelecter.x = 207;
            this._pageSelecter.y = 458;
            this._pageSelecter.pageTextBoxSize = 50;
            this.addChild(this._pageSelecter);
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChange);
            this._btnRefresh = ObjCreate.createGButton(Language.getString(42213), 610, 457, 54, 22, this);
            this._btnRefresh.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnRefreshClick);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this.getList();
            return;
        }

        /* internal  */onBtnRefreshClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.getList();
            return;
        }

        /* internal  */onChange(arg1: Object /* flash.events.Event */): void
        {
            this.getList();
            return;
        }

        /* internal  */getList(): void
        {
            var loc1=new PageData();
            loc1.pageNum = this._pageSelecter.currentPage;
            loc1.pageSize = this.pageSize;
            Dispatcher.dispatchEvent(new DataEvent(EventName.WrestleGetViedoList, loc1));
            return;
        }

        public updateVideoList(arg1: SWrestleFightRecordInfos): void
        {
            this._recordInfos = arg1;
            this._pageSelecter.maxPage = arg1.pageNum;
            this._pageSelecter.currentPage = arg1.page;
            this.updateList();
            this.updateVisible();
            return;
        }

        /* internal  */updateList(): void
        {
            if (this._recordInfos.records.length > 0) 
            {
                this._viedoListPanel.dataProvider = new DataProvider(this._recordInfos.records);
                this._viedoListPanel.drawNow();
            }
            return;
        }

        /* internal  */updateVisible(): void
        {
            var loc1=this._recordInfos && this._recordInfos.records.length > 0;
            this._viedoListPanel.visible = loc1;
            this._tfNoResult.visible = !loc1;
            return;
        }

        /* internal */ /* const */pageSize: int=10;

        /* internal */ /* var */_tfNoResult: Object /* flash.text.TextField */;

        /* internal */ /* var */_viedoListPanel: TilePanel;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_btnRefresh: GButton;

        /* internal */ /* var */_recordInfos: SWrestleFightRecordInfos;
    }
